package com.example.test.bean;

import org.springframework.stereotype.Component;

/**
 * 将配置文件中配置的每一个值映射到当前组件中,配置文件名：application-{profile}.properties/yml
 * 1.@ImportResource(locations="classpath:beans.xml") 导入Spring配置【文件】
 * 2.@Configuration与@Bean 指明当前类为配置类,将方法的返回值添加到容器中(以方法名为组件默认ID)导入SpringBoot配置【类】
 * 2.@PropertySource(value={"classpath:user.properties"}) 读取指定配置文件中的配置参数
 * 3.@ConfigurationProperties(prefix="") :告诉SpringBoot将本类中所有属性和配置文件中相关配置进行绑定
 *                                      prefix参数选择配置文件中的类进行映射(只有 @Component:容器组件 才能进行映射,且需导入spring-boot-Configuration-processor配置文件)
 * 4.@Values Spring的配置,只能一个一个属性进行映射,不能对数据进行校验(@Email)
 * 5.配置文件占位符和指定默认值：$(random.value)和${user.hello:hello}_dog
 * 6.激活指定配置文件：1.在SpringBoot启动项 Program arguments设置 --spring.profiles.active=dev
 *                  2.在SpringBoot启动项 VM options 设置 -Dspring.profiles.active=dev
 *                  2.在配置文件中设置spring.profiles.active=dev
 *                  3.yml里使用文档块激活
 *                  配置文件先设置 profiles:dev/prod(默认)
 */
@Component

public class User {
    private  Integer id;
    private String username;
    private String password;
    private String email;

    public User() {
    }
    public User(Integer id, String username, String password, String email) {
        this.id = id;
        this.username = username;
        this.password = password;
        this.email = email;
    }
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", email='" + email + '\'' +
                '}';
    }
}
